home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C26 / ProcessApplication.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  1.4 KB  |  43 lines

  1. //: C26:ProcessApplication.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. //{L} FormData
  7. #include "FormData.h"
  8. #include "../require.h"
  9. using namespace std;
  10.  
  11. const string from("Bruce@EckelObjects.com");
  12. const string replyto("Bruce@EckelObjects.com");
  13. const string basepath("/home/eckel");
  14.  
  15. int main(int argc, char* argv[]) {
  16.   requireArgs(argc, 1);
  17.   FormData fd(argv[1]);
  18.   char tfname[L_tmpnam];
  19.   tmpnam(tfname); // Create a temporary file name
  20.   string tempfile(basepath + tfname + fd.email);
  21.   ofstream reply(tempfile.c_str());
  22.   assure(reply, tempfile.c_str());
  23.   reply << "This message is to verify that you "
  24.     "have been added to the list for the "
  25.     << fd["subject-field"] << ". Your signup "
  26.     "form included the following data; please "
  27.     "ensure it is correct. You will receive "
  28.     "further updates via email. Thanks for your "
  29.     "interest in the class!" << endl;
  30.   FormData::iterator i;
  31.   for(i = fd.begin(); i != fd.end(); i++)
  32.     reply << (*i).first << " = " 
  33.        << (*i).second << endl;
  34.   reply.close();
  35.   // "fastmail" only available on Linux/Unix:
  36.   string command("fastmail -F " + from + 
  37.     " -r " + replyto + " -s \"" + 
  38.     fd["subject-field"] + "\" " +
  39.     tempfile + " " + fd.email);
  40.   system(command.c_str()); // Wait to finish
  41.   remove(tempfile.c_str()); // Erase the file
  42. } ///:~
  43.